<template>
	<view class="page">
		<view class="authItem frist" @tap.stop="openAuth('ACCESS_FINE_LOCATION')">地理位置权限</view>
		<view class="authItem" @tap.stop="openAuth('WRITE_EXTERNAL_STORAGE')">存储空间/照片权限</view>
		<view class="authItem" @tap.stop="openAuth('CAMERA')">相机权限</view>
		<view class="authItem" @tap.stop="openAuth('RECORD_AUDIO')">麦克风权限</view>
		<view class="authItem" @tap.stop="openAuth('CALL_PHONE')">拨打电话权限</view>
		<permission-popup ref="authpup" type="top" @changeAuth="changeAuth" :permissionID="permissionID"></permission-popup>
		 
	</view>
</template>

<script>
	import permissionPopup from "@/components/permission-popup/permission-popup";
	export default {
		data() {
			return {
				permissionID:''
			}
		},
		components: {
			permissionPopup
		},
		onLoad() {
			
		},
		methods: {
			//打开自定义权限目的弹框
			openAuth(permissionID){
				this.permissionID = permissionID;//这个是对应的权限 ACCESS_FINE_LOCATION 位置权限 / WRITE_EXTERNAL_STORAGE 存储空间/照片权限 / CAMERA相机权限 / CALL_PHONE 拨打电话
				setTimeout(()=>{
					this.$refs['authpup'].open();
				},500)
			},
			//用户授权权限后的回调
			changeAuth(){
				//这里是权限通过后执行自己的代码逻辑
				console.log('权限已授权，可执行自己的代码逻辑了');
			}
		}
	}
</script>

<style>
	.authItem{
		border: solid 2rpx #f5f5f5;
		width: 705rpx;
		margin: 32rpx 22.5rpx 0 22.5rpx;
		padding: 24rpx;
		border-radius: 12rpx;
		/* #ifndef APP-NVUE */
		box-sizing: border-box;
		/* #endif */
		/* #ifdef APP-NVUE */
		flex-direction: row;
		justify-content: center;
		align-items: center;
		/* #endif */
		color: #666;
		text-align: center;
		background: #fff;
	}
</style>
